#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
 
bool vis[21][21];
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
int m = 0, n = 0, cnt = 0;
/*
1. “.”：黑色的瓷砖；
2. “#”：白色的瓷砖；
3. “@”：黑色的瓷砖，并且你站在这块瓷砖上
*/
void dfs(vector<vector<char>>& arr, int sr, int sc)
{
    ++cnt;
    vis[sr][sc] = true;
    for(int i = 0; i < 4; ++i)
    {
        int x = sr + dx[i], y = sc + dy[i];
        if(x >= 0 && x < m && y >= 0 && y < n 
            && !vis[x][y] && arr[x][y] == '.')
        {
            dfs(arr, x, y);
        }
    }
}
 
int main()
{
    while(cin >> m >> n)
    {
        cnt = 0;
        memset(vis, 0, sizeof(vis));
        vector<vector<char>> arr(m, vector<char>(n));
        int sr = 0, sc = 0;
        for(int i = 0; i < m; ++i)
        {
            for(int j = 0; j < n; ++j)
            {
                cin >> arr[i][j];
                if(arr[i][j] == '@')
                    sr = i, sc = j;
            }
        }
        dfs(arr, sr, sc);
        cout << cnt << endl;
    }
    return 0;
}